import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

public class MainMenu extends World {
    public MainMenu() {    
        super(600, 400, 1); 
        showText("选择难度", 300, 50);
        
        // 添加简单按钮
        addObject(new DifficultyButton("简单", Table.EASY,600,400), 150, 200);
        // 添加普通按钮
        addObject(new DifficultyButton("普通", Table.MEDIUM,600,500), 300, 200);
        // 添加困难按钮
        addObject(new DifficultyButton("困难", Table.HARD,600,700), 450, 200);
    }
}

// 创建按钮类
class DifficultyButton extends Actor {
    private int difficulty;
    private int hight,width;
    public DifficultyButton(String _label, int _difficulty,int _hight,int _width) {
        difficulty = _difficulty;
        hight=_hight;
        width=_width;
        setImage(new GreenfootImage(_label, 24, Color.WHITE, Color.BLACK));
    }

    public void act() {
        if (Greenfoot.mouseClicked(this)) {
            Greenfoot.setWorld(new Table(difficulty,hight,width)); // 进入游戏
        }
    }
}
